import Vue from 'vue';
import Vuex from 'vuex';
import app from './modules/app';
import user from './modules/user';
import dict from './modules/dict'
import tagsView from './modules/tagsView';
import permission from './modules/permission';
import settings from './modules/settings';
import socket from './modules/socket';
import commonData from './modules/commonData';
import getters from './getters';

Vue.use(Vuex);

const store = new Vuex.Store({
  modules: {
    app,
    dict,
    user,
    tagsView,
    permission,
    settings,
    socket,
    commonData
  },
  getters,
});
// 监听 store 变化，通知主应用
store.subscribe((mutation, state) => {
  if (window.$wujie&&window.$wujie.props&&window.$wujie.props.onSubAppStoreUpdate) {
    window.$wujie.props.onSubAppStoreUpdate(state);
  }
});
export default store;
